<?php require_once('Connections/aciitu.php'); ?>
<?php
if (!isset($_POST['uso']) or $_POST['uso'] == "") { $_POST['uso'] = ""; }
if (!isset($_POST['tipo_imovel']) or $_POST['tipo_imovel'] == "") { $_POST['tipo_imovel'] = ""; }
if (!isset($_POST['cidade']) or $_POST['cidade'] == "") { $_POST['cidade'] = ""; }
if (!isset($_POST['titulo']) or $_POST['titulo'] == "") { $_POST['titulo'] = ""; }

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_aciitu, $aciitu);
$query_RsUso = "SELECT * FROM anuncio_tipo";
$RsUso = mysql_query($query_RsUso, $aciitu) or die(mysql_error());
$row_RsUso = mysql_fetch_assoc($RsUso);
$totalRows_RsUso = mysql_num_rows($RsUso);

mysql_select_db($database_aciitu, $aciitu);
$query_RsTipoImovel = "SELECT * FROM imovel_tipo";
$RsTipoImovel = mysql_query($query_RsTipoImovel, $aciitu) or die(mysql_error());
$row_RsTipoImovel = mysql_fetch_assoc($RsTipoImovel);
$totalRows_RsTipoImovel = mysql_num_rows($RsTipoImovel);

mysql_select_db($database_aciitu, $aciitu);
$query_RsCidImovel = "SELECT cidade FROM imovel where status = 1 group by cidade ASC";
$RsCidImovel = mysql_query($query_RsCidImovel, $aciitu) or die(mysql_error());
$row_RsCidImovel = mysql_fetch_assoc($RsCidImovel);
$totalRows_RsCidImovel = mysql_num_rows($RsCidImovel);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
-->
</style></head>

<body>

<form action="busca_imoveis.php" method="post" name="buscar_imovel">

<table width="973" height="88" border="0" cellspacing="0" cellpadding="0" background="imagens/fundo_busca.jpg" style="background-repeat:no-repeat; background-position:top;">
  <tr>
    <td width="236" height="38">&nbsp;</td>
    <td width="78">&nbsp;</td>
    <td width="19">&nbsp;</td>
    <td width="148">&nbsp;</td>
    <td width="20">&nbsp;</td>
    <td width="149">&nbsp;</td>
    <td width="20">&nbsp;</td>
    <td width="218">&nbsp;</td>
    <td width="15">&nbsp;</td>
    <td width="46">&nbsp;</td>
    <td width="24">&nbsp;</td>
  </tr>
  <tr>
    <td height="26">&nbsp;</td>
    <td align="right">
    	<select name="uso" id="uso" style="font-size:11px; font-family:Arial; background:#F0F0F0; border:none; width:78px; height:24px;">
          <option value=""></option>
      <?php do { ?>
          <option value="<?php echo $row_RsUso['id']; ?>" <?php if($row_RsUso['id'] == $_POST['uso']){ echo "selected='selected'"; } ?>><?php echo $row_RsUso['nome']; ?></option>
        <?php } while ($row_RsUso = mysql_fetch_assoc($RsUso)); ?>
        </select>
    </td>
    <td>&nbsp;</td>
    <td align="right">
    	<select name="tipo_imovel" id="tipo_imovel" style="font-size:11px; font-family:Arial; background:#F0F0F0; border:none; width:147px; height:24px;">
          <option value=""></option>
      <?php do { ?>
          <option value="<?php echo $row_RsTipoImovel['id']; ?>" <?php if($row_RsTipoImovel['id'] == $_POST['tipo_imovel']){ echo "selected='selected'"; } ?>><?php echo $row_RsTipoImovel['nome']; ?></option>
        <?php } while ($row_RsTipoImovel = mysql_fetch_assoc($RsTipoImovel)); ?>
        </select>
    </td>
    <td>&nbsp;</td>
    <td align="right">
    	<select name="cidade" id="cidade" style="font-size:11px; font-family:Arial; background:#F0F0F0; border:none; width:148px; height:24px;">
          <option value=""></option>
      <?php do { ?>
          <option value="<?php echo $row_RsCidImovel['cidade']; ?>" <?php if($row_RsCidImovel['cidade'] == $_POST['cidade']){ echo "selected='selected'"; } ?>><?php echo $row_RsCidImovel['cidade']; ?></option>
        <?php } while ($row_RsCidImovel = mysql_fetch_assoc($RsCidImovel)); ?>
        </select>
    </td>
    <td>&nbsp;</td>
    <td><input name="titulo" type="text" maxlength="50" <?php if($_POST['titulo'] <> ""){ echo "value=".$_POST['titulo']; } ?> style="font-size:11px; width:210px; border:none; background:none; height:24px; padding-left:4px; padding-right:4px;" /></td>
    <td>&nbsp;</td>
    <td><input type="submit" value="&nbsp;" title="Fazer Busca" style="background:none; border:none; width:46px; height:26px;" /></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="24">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

</form>

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-40174296-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

</body>
</html>
<?php
mysql_free_result($RsUso);

mysql_free_result($RsTipoImovel);

mysql_free_result($RsCidImovel);
?>
